package com.example.listgame.fragment;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.listgame.DBOpenHelper;
import com.example.listgame.R;

import java.util.logging.Handler;

public class ListAdapter extends BaseAdapter {

    private Context mContext;
    private LayoutInflater mLayoutInflater;
    private  int arg;

    public ListAdapter(Context context,int arg) {
        this.mContext = context;
        mLayoutInflater = LayoutInflater.from(context);
        this.arg = arg;
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    static class ViewHolder {
        public TextView mTvRanking, mTvName, mTvCourse;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null){
            view = mLayoutInflater.inflate(R.layout.layout_ranking_item,null);
            holder = new ViewHolder();
            holder.mTvRanking = view.findViewById(R.id.tv_ranking);
            holder.mTvName = view.findViewById(R.id.tv_name);
            holder.mTvCourse = view.findViewById(R.id.tv_course);
            view.setTag(holder);
        }else {
            holder = (ViewHolder) view.getTag();
        }
                //给控件赋值
                holder.mTvRanking.setText(i+1);
                holder.mTvName.setText("");
                holder.mTvCourse.setText("");
        return view;
    }

}
